App.controller('processController', ['$scope', '$state', '$stateParams', 'Page', function($scope, $state, $stateParams, Page) {
	 $scope.grid = {
		        column_defs: [
					{
					    target: 1,
					    template: function (row) {
					        return '<a href="javascript:void(0);;" ed-click="browser">' + row.processInstanceId + '</a>'
					    }
					},{
		                target: 7,
		                buttons: [
		                    {
		                        name: '删除',
		                        class: 'btn-delete',
		                        icon: 'fa-trash-o',
		                        visiable: function(row) {
									return true;
		                    	},
		                        event: function(row, btn) {
		                    		if(row.superProcessInstanceId 
		                    				&& row.superProcessInstanceId != '' 
		                    				&& row.endTime == ''){
		                    			Page.alert("请首先删除关联流程实例["+row.superProcessInstanceId+"]!");
		                    			return;
		                    		}
		                            Page.ajaxPost('bpm/process/' + row.processInstanceId + '/delete.do', {deleteBusiness : true}, function(resp) {
		                                Page.alert('删除流程实例成功!');
		                                $scope.grid.query();
		                            });
		                        }
		                    }
		                ]
		            }
		            
		        ],
		        browser: function (row) {
		 			$state.go('auth.processView', {processInstanceId: row.processInstanceId});
	            }
	 }
    	
}]);
